package com.zhuanyongjin.server;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.zhuanyongjin.dao.membersDao;
import com.zhuanyongjin.dao.platform_activityDao;
import com.zhuanyongjin.dao.impl.membersDaoImpl;
import com.zhuanyongjin.dao.impl.platform_activityDaoImpl;

public class platform_activityServlet extends HttpServlet {

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		platform_activityDao platform_activitys = new platform_activityDaoImpl();
		//获取平台活动对应的子页面的内容
		String category_id=request.getParameter("cat_id");
		List list1=platform_activitys.queryGetSidebar(category_id);
		if(list1.size()>0){
			JSONArray json=JSONArray.fromObject(list1);	
			out.print(json);
			System.out.println("success!");
		}
		else
		{
			out.println("error");
		}
		out.close();
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
